package com.vichat.task;

import com.alibaba.dubbo.container.spring.SpringContainer;
import com.vichat.common.util.DateUtil;
import com.vichat.online.service.IOnlineService;
import com.vichat.task.service.ITask;
import com.vichat.user.service.IUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * Created by wangluyin on 2017/1/24.
 * 当天登录时长统计，执行频率1小时1次
 */
@Component("OnlineUserLogTask")
public class OnlineUserLogTask implements ITask {

    private static transient final Logger logger = LoggerFactory.getLogger(OnlineUserLogTask.class);


    @Override
    public String doTask(long cfgTaskId) throws Exception {

        ApplicationContext ctx = SpringContainer.getContext();
        IOnlineService onlineService = (IOnlineService) ctx.getBean("onlineService", IOnlineService.class);

        String today = DateUtil.getFormattedDate(new Date(),"yyyyMMdd");
        onlineService.processOnlineUserLog(today);
        return null;
    }
}
